package com.rtx.wms.std.adjustment.controller;


import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.rtx.wms.std.adjustment.handle.AdjustmentSchedulerHandle;
import com.rtx.wms.std.adjustment.service.AdjustmentService;
import com.rtx.wms.std.common.bean.WmsConstant;
import com.rtx.wms.std.common.service.CommonService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * @author hkjun
 * @date 2023-12-18
 */
@Api(tags = {"调整单"})
@RestController
@RequestMapping("/adjustment")
public class AdjustmentController {
	
	Logger log = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
	AdjustmentService adjustmentService;

	private Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private AdjustmentSchedulerHandle adjustmentSchedulerHandle;

	@Autowired
	private CommonService commonService;

	/**
	 * 发送调整单申请-测试
	 * @param 
	 * @throws 
	 */
	@ApiOperation(value = "发送调整单申请-测试")
	@PostMapping("/adjustmentSend")
	public void adjustmentSend() {
		//激活的仓库
		List<String> whseidList = commonService.selectActiveWhseidNotEnterprise(WmsConstant.ENTERPRISE);
		for(String whseid : whseidList){
			try {
				adjustmentSchedulerHandle.handlerAdjustmentSend(whseid);
			} catch (Exception e) {
				logger.error("仓库{}出库单回传写入中间表异常",whseid,e);
			}
		}
	}
}
